﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media.Imaging;


namespace GuiaCiudad.View
{
  public  class ObjectToBitmapImage: IValueConverter{




        public  object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

             var localfolder = Windows.Storage.ApplicationData.Current.LocalFolder;
             var folderToSave =  localfolder.CreateFolderAsync("Fotos",Windows.Storage. CreationCollisionOption.OpenIfExists);

                   
                   
               //   var file = 
            //var file =  folderToSave.CreateFileAsync(name,Windows.Storage.CreationCollisionOption.ReplaceExisting);

                 //   var stream = await file.OpenStreamForWriteAsync();

                  

                  //  System.Xml.Serialization.XmlSerializer xs = new XmlSerializer(Fotos.GetType());

                   // DataContractSerializer ds = new DataContractSerializer(o.GetType());

                   // xs.Serialize(stream, Fotos);

                    //ds.WriteObject(stream, Fotos);


            //        System.Net.WebClient wc = new System.Net.WebClient();
            //        wc.OpenReadCompleted += async (obj, e) => {

            //           await e.Result.CopyToAsync(stream);
            //            stream.Close();
            //            stream = await file.OpenStreamForReadAsync();
            //            System.Windows.Media.Imaging.BitmapImage Bi = new System.Windows.Media.Imaging.BitmapImage();
            //            Bi.SetSource(stream);

            return new object();

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
